﻿using Engine;
using Engine.Graphics;
using Game;

namespace SAGhoul.Blocks
{
	public class LargeSoulsResidueBlock : Block
    {
        public BlockMesh m_standaloneBlockMesh = new();
        public Game.Random m_random = new();
        public override void Initialize()
        {
            Model model = ContentManager.Get<Model>("Models/ChunkSmooth");
            Matrix matrix = BlockMesh.GetBoneAbsoluteTransform(model.Meshes[0].ParentBone);
            m_standaloneBlockMesh.AppendModelMeshPart(model.Meshes[0].MeshParts[0], matrix, makeEmissive: true, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            m_standaloneBlockMesh.TransformTextureCoordinates(Matrix.CreateScale(16f));
            base.Initialize();
        }

        public override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometry geometry, int value, int x, int y, int z)
        {
        }

        public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
        {
            BlocksManager.DrawMeshBlock(primitivesRenderer, m_standaloneBlockMesh, SAGhoulsManager.AnimateTextureByTime, Color.White, 2f * size, ref matrix, environmentData);
        }

		public override BlockDebrisParticleSystem CreateDebrisParticleSystem(SubsystemTerrain subsystemTerrain, Vector3 position, int value, float strength)
		{
			return new BlockDebrisParticleSystem(subsystemTerrain, position, strength, DestructionDebrisScale, Color.White, 0, SAGhoulsManager.AnimateTextureByTime);
		}
	}
}
